package com.third.clock.common;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018/7/31 0031.
 */

public enum CodeEnum{
    Code_0(Contants.CODE_0,"成功"),
    Code_1(Contants.CODE_1,"失败"),
    Code_101(Contants.CODE_101,"手机号，密码为空"),
    Code_102(Contants.CODE_102,"签名失败"),
    Code_105(Contants.CODE_105,"用户名不存在"),
    Code_107(Contants.CODE_107,"密码错误"),
    Code_404(Contants.CODE_404,"未知错误"),
    ;


    public int code;

    public String codetext;

    CodeEnum(int code,String codetext){
        this.code=code;
        this.codetext=codetext;
    }

    static Map<Integer, CodeEnum> mCodes;

    static {
        mCodes = new HashMap<>();
        for (CodeEnum codeEnum : CodeEnum.values()) {
            mCodes.put(codeEnum.code, codeEnum);
        }
    }

    public static CodeEnum get(int code) {
        CodeEnum mCodeEnum=null;
        mCodeEnum=mCodes.get(code);
        if(mCodeEnum==null){
            mCodeEnum=mCodes.get(Contants.CODE_404);
        }
        return mCodeEnum;
    }

}
